import java.util.Scanner;
import java.util.Stack;
import java.util.*;

public class Test {
    //3.点击消除 AB5
    //3.1使用栈
    public static void main3(String[] args){

        //1.输入一个字符串
        Scanner in = new Scanner(System.in);
        String str = in.nextLine().toLowerCase();

        //使用一个栈
        Stack<Character> stack = new Stack<>();

        stack.push(str.charAt(0));

        StringBuilder st = new StringBuilder();

        for(int i = 1;i < str.length();i++){

            if(stack.size() != 0 && str.charAt(i) == stack.peek()){
                stack.pop();
            }else{
                stack.push(str.charAt(i));
            }

        }

        if(stack.size() == 0){
            System.out.println(0);
        }

        while(!stack.empty()){
            st.append(stack.pop());
        }

        System.out.println(st.reverse().toString());

    }
    //3.2 使用StringBuilder模拟栈的使用
    public static void main(String[] args){

        Scanner in = new Scanner(System.in);
        String str = in.nextLine();

        //模拟出入栈
        StringBuilder st = new StringBuilder();

        st.append(str.charAt(0));

        for(int i = 1;i < str.length();i++){

            if(st.length() != 0 && st.charAt(st.length() - 1) == str.charAt(i)){
                st.deleteCharAt(st.length() - 1);
            }else{
                st.append(str.charAt(i));
            }
        }

        if(st.length() == 0){
            System.out.println(0);
        }else{
            System.out.println(st.toString());
        }
    }

    //求交集
    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        //使用哈希表
        HashSet<Integer> map = new HashSet<>();

        for(int i = 0;i < nums1.size();i++){
            map.add(nums1.get(i));
        }

        ArrayList<Integer> ret = new ArrayList<>();

        for(int j = 0; j < nums2.size();j++){

            if(map.contains(nums2.get(j))){
                ret.add(nums2.get(j));
                map.remove(nums2.get(j));
            }

        }

        return ret;
    }
    public ArrayList<Integer> intersection1 (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        //模拟哈希表
        boolean[] num1 = new boolean[1001];
        for(int i = 0;i < nums1.size();i++){
            num1[nums1.get(i)] = true;
        }

        ArrayList<Integer> ret = new ArrayList<>();

        for(int j = 0; j < nums2.size();j++){

            if(num1[nums2.get(j)]){
                ret.add(nums2.get(j));
                num1[nums2.get(j)] = false;
            }

        }

        return ret;
    }


    //1.统计数字2出现的次数：BC153
    public static void main1(String[] args) {

        //1.输入一个范围
        Scanner in = new Scanner(System.in);
        int left = in.nextInt();
        int right = in.nextInt();

        //2.遍历 + 统计
        int cnt = 0;
        for(int i = left;i <= right;i++){
            int tem = i;
            while(tem > 0){
                if(tem % 10 == 2){
                    cnt++;
                }
                tem /= 10;
            }
        }
    //3.输出
        System.out.println(cnt);

    }
}
